home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 2 / Atari Mega Archive CD - Volume 2.iso / minix / file2dsk.c < prev    next >
C/C++ Source or Header  |  1995-04-22  |  2KB  |  92 lines

  1. /*
  2.     File to disk moving utility for the Atari ST
  3. */
  4.  
  5. #include <stdio.h>
  6.  
  7. char buffer[4610];
  8. main(argc,argv)
  9. int argc;
  10. char *argv[];
  11. {
  12.  
  13.     int i,handle,result=1,drive=0,sector=1,track=0,side=0,done,count=0;
  14.     char dummy[255];
  15.     long filler=0,buflen=4608;
  16.     FILE *infile;
  17.     
  18.     printf("file2dsk.ttp  --  (c)1991 Ken Corey (aka kenc@vaxb.acs.unt.edu)\n");
  19.     printf("Intended for use with the demonstration distribution of \n MINIX-ST (c)1990 Prentice Hall\n"); 
  20.     if(argc<2)
  21.     {
  22.         printf("\nThis program will transfer a file onto a disk bit for bit.\n");
  23.         printf("It's meant to be used with the Minix demo software, though it will\n");
  24.         printf("use any file.  Use with other files will no doubt lead to\n");
  25.         printf("interesting deadly, and useless (8^)) results.\n");
  26.         printf("\nUsage: file2dsk demo_dsk.st [B:]\n");
  27.         printf("\nwill copy the file demo_dsk.st onto a floppy, bit for bit, sector for sector.\n");
  28.         printf("2 Caveats:\n\n");
  29.         printf("  1)This software will completely erase any extant info on the floppy.\n");
  30.         printf("\n  2)The disk must previously be formatted out to single sided,\n");
  31.         printf("    using the standard st desktop.  No other configuration has been tested!\n");
  32.         printf("\n\n BTW, have a great day!\n");
  33.  
  34.         printf("Hint: hit a key to exit to desktop....");
  35.         gets(dummy);
  36.         exit(1);
  37.     }
  38.  
  39.     if(argc==3)
  40.         drive=1;
  41.     printf("\nOkay, I'm gonna use '%s' as the filename.\n",argv[1]);
  42.     printf("Please insert a freshly formatted, SINGLE sided floppy in drive ");
  43.     if(drive==0)
  44.         printf("A:\n");
  45.     else
  46.         printf("B:\n");
  47.     printf("and hit return...\n\n");
  48.     printf("THIS FLOPPY WILL BE COMPLETELY ERASED!");
  49.  
  50.     gets(dummy);
  51.     
  52.     result=gemdos(0x3D,argv[1],0);
  53.     if (result<0)
  54.     {
  55.         printf("I couldn't open the file '%s'!\n",argv[1]);
  56.         exit(result);
  57.     }
  58.  
  59.     handle=result;
  60.  
  61.     while((track<=80)&&(count<0x2D0)&&(done!=1))
  62.     {
  63.         for(i=0;i<4610;buffer[i++]=0xE5) ;
  64.         
  65.         result=gemdos(0x3F,handle,buflen,&buffer[0]);
  66.         if (result<0)
  67.         {
  68.             printf("Error in reading '%s'!\n",argv[1]);
  69.             exit(result);
  70.         }
  71.  
  72.         if(result==0)
  73.             done=1;
  74.  
  75.         printf("%d--%d t--s\n",track,sector);
  76.  
  77.         result=xbios(0x9,&buffer[0],filler,drive,sector,track,side,9);
  78.         if(result<0)
  79.         {
  80.             printf("Error in writing to drive A:!\n");
  81.             exit(result);
  82.         }
  83.  
  84.         track += 1;
  85.         count += 9;
  86.     }
  87.  
  88.     printf("All done!\n");
  89.  
  90. }
  91.     
  92.